<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>for循环语句</title>
</head>
<body>
    <div id="app">
        <!-- 开始使用 vue.js语句 -->
        <ul>
            <li v-for="stu in students">姓名：{{ stu.name }}, {{stu.age }}岁,</li>
        </ul>
        <table>
            <tr>
                <td>序号</td>
                <td>姓名</td>
                <td>性别</td>
            </tr>
            <tr v-for="(stu, index) in students">
                <td>{{ index + 1 }}</td>
                <td>{{stu.name}}</td>
                <td>{{stu.sex}}</td>
            </tr>
        </table>
    </div>
</body>
<script src="vue.js"></script>
<script>
    new Vue({
        el: "#app",
        data: {
            // 假设从数据库得到内容(3个同学姓名)
            students :[
                {name: "张三", sex: "男", age: 16},
                {name: "李四", sex: "女", age: 17},
                {name: "陈五", sex: "女", age: 20}
            ]
        }
    })
</script>
</html>